# Reproduce results of Table 1
# R version 4.1.1 (2021-08-10)
#
# These commands take substantial time to run

R CMD BATCH --no-save --no-restore '--args 4 4' gridstep-aws.R gridstep-aws-4-4.out &
R CMD BATCH --no-save --no-restore '--args 4 5' gridstep-aws.R gridstep-aws-4-5.out &
R CMD BATCH --no-save --no-restore '--args 4 6' gridstep-aws.R gridstep-aws-4-6.out &
R CMD BATCH --no-save --no-restore '--args 4 7' gridstep-aws.R gridstep-aws-4-7.out &
R CMD BATCH --no-save --no-restore '--args 4 8' gridstep-aws.R gridstep-aws-4-8.out &
R CMD BATCH --no-save --no-restore '--args 4 9' gridstep-aws.R gridstep-aws-4-9.out &
R CMD BATCH --no-save --no-restore '--args 4 10' gridstep-aws.R gridstep-aws-4-10.out &
R CMD BATCH --no-save --no-restore '--args 4 11' gridstep-aws.R gridstep-aws-4-11.out &
R CMD BATCH --no-save --no-restore '--args 4 12' gridstep-aws.R gridstep-aws-4-12.out &
R CMD BATCH --no-save --no-restore '--args 5 4' gridstep-aws.R gridstep-aws-5-4.out &
R CMD BATCH --no-save --no-restore '--args 5 5' gridstep-aws.R gridstep-aws-5-5.out &
R CMD BATCH --no-save --no-restore '--args 5 6' gridstep-aws.R gridstep-aws-5-6.out &
R CMD BATCH --no-save --no-restore '--args 5 7' gridstep-aws.R gridstep-aws-5-7.out &
R CMD BATCH --no-save --no-restore '--args 5 8' gridstep-aws.R gridstep-aws-5-8.out &
R CMD BATCH --no-save --no-restore '--args 5 9' gridstep-aws.R gridstep-aws-5-9.out &
R CMD BATCH --no-save --no-restore '--args 5 10' gridstep-aws.R gridstep-aws-5-10.out &
R CMD BATCH --no-save --no-restore '--args 5 11' gridstep-aws.R gridstep-aws-5-11.out &
R CMD BATCH --no-save --no-restore '--args 5 12' gridstep-aws.R gridstep-aws-5-12.out &
R CMD BATCH --no-save --no-restore '--args 6 4' gridstep-aws.R gridstep-aws-6-4.out &
R CMD BATCH --no-save --no-restore '--args 6 5' gridstep-aws.R gridstep-aws-6-5.out &
R CMD BATCH --no-save --no-restore '--args 6 6' gridstep-aws.R gridstep-aws-6-6.out &
R CMD BATCH --no-save --no-restore '--args 6 7' gridstep-aws.R gridstep-aws-6-7.out &
R CMD BATCH --no-save --no-restore '--args 6 8' gridstep-aws.R gridstep-aws-6-8.out &
R CMD BATCH --no-save --no-restore '--args 6 9' gridstep-aws.R gridstep-aws-6-9.out &
R CMD BATCH --no-save --no-restore '--args 6 10' gridstep-aws.R gridstep-aws-6-10.out &
R CMD BATCH --no-save --no-restore '--args 6 11' gridstep-aws.R gridstep-aws-6-11.out &
R CMD BATCH --no-save --no-restore '--args 6 12' gridstep-aws.R gridstep-aws-6-12.out &
R CMD BATCH --no-save --no-restore '--args 7 4' gridstep-aws.R gridstep-aws-7-4.out &
R CMD BATCH --no-save --no-restore '--args 7 5' gridstep-aws.R gridstep-aws-7-5.out &
R CMD BATCH --no-save --no-restore '--args 7 6' gridstep-aws.R gridstep-aws-7-6.out &
R CMD BATCH --no-save --no-restore '--args 7 7' gridstep-aws.R gridstep-aws-7-7.out &
R CMD BATCH --no-save --no-restore '--args 7 8' gridstep-aws.R gridstep-aws-7-8.out &
R CMD BATCH --no-save --no-restore '--args 7 9' gridstep-aws.R gridstep-aws-7-9.out &
R CMD BATCH --no-save --no-restore '--args 7 10' gridstep-aws.R gridstep-aws-7-10.out &
R CMD BATCH --no-save --no-restore '--args 7 11' gridstep-aws.R gridstep-aws-7-11.out &
R CMD BATCH --no-save --no-restore '--args 7 12' gridstep-aws.R gridstep-aws-7-12.out &
R CMD BATCH --no-save --no-restore '--args 8 4' gridstep-aws.R gridstep-aws-8-4.out &
R CMD BATCH --no-save --no-restore '--args 8 5' gridstep-aws.R gridstep-aws-8-5.out &
R CMD BATCH --no-save --no-restore '--args 8 6' gridstep-aws.R gridstep-aws-8-6.out &
R CMD BATCH --no-save --no-restore '--args 8 7' gridstep-aws.R gridstep-aws-8-7.out &
R CMD BATCH --no-save --no-restore '--args 8 8' gridstep-aws.R gridstep-aws-8-8.out &
R CMD BATCH --no-save --no-restore '--args 8 9' gridstep-aws.R gridstep-aws-8-9.out &
R CMD BATCH --no-save --no-restore '--args 8 10' gridstep-aws.R gridstep-aws-8-10.out &
R CMD BATCH --no-save --no-restore '--args 8 11' gridstep-aws.R gridstep-aws-8-11.out &
R CMD BATCH --no-save --no-restore '--args 8 12' gridstep-aws.R gridstep-aws-8-12.out &
R CMD BATCH --no-save --no-restore '--args 9 4' gridstep-aws.R gridstep-aws-9-4.out &
R CMD BATCH --no-save --no-restore '--args 9 5' gridstep-aws.R gridstep-aws-9-5.out &
R CMD BATCH --no-save --no-restore '--args 9 6' gridstep-aws.R gridstep-aws-9-6.out &
R CMD BATCH --no-save --no-restore '--args 9 7' gridstep-aws.R gridstep-aws-9-7.out &
R CMD BATCH --no-save --no-restore '--args 9 8' gridstep-aws.R gridstep-aws-9-8.out &
R CMD BATCH --no-save --no-restore '--args 9 9' gridstep-aws.R gridstep-aws-9-9.out &
R CMD BATCH --no-save --no-restore '--args 9 10' gridstep-aws.R gridstep-aws-9-10.out &
R CMD BATCH --no-save --no-restore '--args 9 11' gridstep-aws.R gridstep-aws-9-11.out &
R CMD BATCH --no-save --no-restore '--args 9 12' gridstep-aws.R gridstep-aws-9-12.out &
R CMD BATCH --no-save --no-restore '--args 10 4' gridstep-aws.R gridstep-aws-10-4.out &
R CMD BATCH --no-save --no-restore '--args 10 5' gridstep-aws.R gridstep-aws-10-5.out &
R CMD BATCH --no-save --no-restore '--args 10 6' gridstep-aws.R gridstep-aws-10-6.out &
R CMD BATCH --no-save --no-restore '--args 10 7' gridstep-aws.R gridstep-aws-10-7.out &
R CMD BATCH --no-save --no-restore '--args 10 8' gridstep-aws.R gridstep-aws-10-8.out &
R CMD BATCH --no-save --no-restore '--args 10 9' gridstep-aws.R gridstep-aws-10-9.out &
R CMD BATCH --no-save --no-restore '--args 10 10' gridstep-aws.R gridstep-aws-10-10.out &
R CMD BATCH --no-save --no-restore '--args 10 11' gridstep-aws.R gridstep-aws-10-11.out &
R CMD BATCH --no-save --no-restore '--args 10 12' gridstep-aws.R gridstep-aws-10-12.out &
R CMD BATCH --no-save --no-restore '--args 11 4' gridstep-aws.R gridstep-aws-11-4.out &
R CMD BATCH --no-save --no-restore '--args 11 5' gridstep-aws.R gridstep-aws-11-5.out &
R CMD BATCH --no-save --no-restore '--args 11 6' gridstep-aws.R gridstep-aws-11-6.out &
R CMD BATCH --no-save --no-restore '--args 11 7' gridstep-aws.R gridstep-aws-11-7.out &
R CMD BATCH --no-save --no-restore '--args 11 8' gridstep-aws.R gridstep-aws-11-8.out &
R CMD BATCH --no-save --no-restore '--args 11 9' gridstep-aws.R gridstep-aws-11-9.out &
R CMD BATCH --no-save --no-restore '--args 11 10' gridstep-aws.R gridstep-aws-11-10.out &
R CMD BATCH --no-save --no-restore '--args 11 11' gridstep-aws.R gridstep-aws-11-11.out &
R CMD BATCH --no-save --no-restore '--args 11 12' gridstep-aws.R gridstep-aws-11-12.out &
R CMD BATCH --no-save --no-restore '--args 12 4' gridstep-aws.R gridstep-aws-12-4.out &
R CMD BATCH --no-save --no-restore '--args 12 5' gridstep-aws.R gridstep-aws-12-5.out &
R CMD BATCH --no-save --no-restore '--args 12 6' gridstep-aws.R gridstep-aws-12-6.out &
R CMD BATCH --no-save --no-restore '--args 12 7' gridstep-aws.R gridstep-aws-12-7.out &
R CMD BATCH --no-save --no-restore '--args 12 8' gridstep-aws.R gridstep-aws-12-8.out &
R CMD BATCH --no-save --no-restore '--args 12 9' gridstep-aws.R gridstep-aws-12-9.out &
R CMD BATCH --no-save --no-restore '--args 12 10' gridstep-aws.R gridstep-aws-12-10.out &
R CMD BATCH --no-save --no-restore '--args 12 11' gridstep-aws.R gridstep-aws-12-11.out &
R CMD BATCH --no-save --no-restore '--args 12 12' gridstep-aws.R gridstep-aws-12-12.out &


# For example, with 4 treated and 4 control clusters,
# R CMD BATCH --no-save --no-restore '--args 4 4' gridstep-aws.R gridstep-aws-4-4.out &
# outputs
# NOT RUN
8% 16% 24% 32% 40% 48% 56% 64% 72% 80% 88% 96% 
Worst-case sd: 0.001 0.001 0.001 0.001 1 1 1 0.001
Rej frequency: 0.1289
8% 16% 24% 32% 40% 48% 56% 64% 72% 80% 88% 96% 
Worst-case sd: 0.001 0.001 0.001 0.001 1 1 1 1
Rej frequency: 0.1246
8% 16% 24% 32% 40% 48% 56% 64% 72% 80% 88% 96% 
Worst-case sd: 1 1 1 0.001 0.01 0.01 0.01 0.01
Rej frequency: 0.1154
8% 16% 24% 32% 40% 48% 56% 64% 72% 80% 88% 96% 
Worst-case sd: 1 1 1 0.001 0.01 0.01 0.01 0.01
Rej frequency: 0.0827
8% 16% 24% 32% 40% 48% 56% 64% 72% 80% 88% 96% 
Worst-case sd: 1 1 1 1 0.01 0.01 0.01 0.01
Rej frequency: 0.0674
8% 16% 24% 32% 40% 48% 56% 64% 72% 80% 88% 96% 
Worst-case sd: 0.001 0.001 0.001 0.001 1 1 1 1
Rej frequency: 0.0639
# END NOT RUN
# and saves 
#
# NOT RUN 
     ks    res
[1,] 64 0.1289
[2,] 65 0.1246
[3,] 66 0.1154
[4,] 67 0.0827
[5,] 68 0.0674
[6,] 69 0.0639
# END NOT RUN
#
# Because the 67th other statistic is has rejection frequency <.1, using level 1-67/choose(4+4,4)=.0428 controls size at 10% level